<template>
 <inputSelect  v-model="fmaterialid" ref="obj"
                :f7Param="f7Param"
                :f7Disable="disabled"
                :title="title"
                :loadShow="loadShow"
                :onF7DaTaSelected="onF7DaTaSelected"
                v-on:onF7DaTaSelected="onF7DaTaSelected"
  >
  </inputSelect>
</template>

<script>
    export default {
        name: "demo-material",
      props:{
        disabled : {type : Boolean},
        value : { type: [Number,String] },
        loadShow : {type:[String]},
        filter : {type : Array,default:null }
      },
      data(){
        return{
          title : '物料列表',
          fmaterialid : null,
          f7Param :{
            selectId:'fid',
            selectUrl:'/tie-mdm/material/queryListPage',
            selectTreeField:['fgroupid'],
            selectTreeUrl:'/tie-mdm/materialGroup/queryGroupTree',
            //selectTreeUrl:'/tie-demo/material/queryGroupTree',
            selectShow:{spt:'',field:['fname']},
            column:[
              {lable:'物料编码',prop:'fnumber',isFilter:false,filterField:'fnumber'},
              {lable:'名称',prop:'fname',isFilter:false,filterField:'fname'},
              {lable:'规格型号',prop:'fmodel',isFilter:false,filterField:'fmodel'},
              {lable:'助记码',prop:'fmnemoniccode',isFilter:false,filterField:'fmnemoniccode'},
              {lable:'基本单位',prop:'fbaseunitname',isFilter:false,filterField:'fbaseunitname'},
              {lable:'辅助单位',prop:'fauxunitname',isFilter:false,filterField:'fauxunitname'},
              {lable:'默认仓库',prop:'fwarehousename',isFilter:true,filterField:'fwarehousename'},
              {lable:'默认库区',prop:'fwareareaname',isFilter:true,filterField:'fwareareaname'},
              {lable:'默认库位',prop:'flocationname',isFilter:true,filterField:'flocationname'},
            ],
            defaultFilter:[{field:'fstatus',value:"USED"}]
          },
        }
      },
      created(){
        if(this.filter != null){
          let realFilter = [];
          realFilter = this.f7Param.defaultFilter.concat(this.filter)
          this.f7Param.defaultFilter = realFilter;
        }
      },
      methods:{
        onF7DaTaSelected(row){
          this.$emit('input',row[this.f7Param.selectId])
          this.$emit('change',row)
        },
        cleanF7(){
          this.$refs.obj.cleanF7()
        },
        defaultSelect(data){
          this.$refs.obj.defaultSelect(data)
        },
        refresh(filters){
          let realFilter = [];
          if(this.filter!=null){
            realFilter = this.f7Param.defaultFilter.concat(this.filter)
          }
          if(filters != null){
            realFilter = realFilter.concat(filters)
          }
          this.f7Param.defaultFilter = realFilter;
          this.$refs.obj.refresh()
        }
      }
    }

</script>

<style scoped>

</style>
